//
//  MyTaskCell.swift
//  willdo
//
//  Created by zz on 3/14/18.
//  Copyright © 2018 will do. All rights reserved.
//

import UIKit
import SnapKit

class MyTaskCell: UITableViewCell {
    
    let bgView = UIImageView()
    let taskName = UILabel()
    let taskTime = UILabel()
    let taskMember = UILabel()
    let taskState = UILabel()
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        backgroundColor = UIColor.clear
        self.selectionStyle = .none
        setupCell()
    }
    
    private func setupCell(){
        addSubview(bgView)
        bgView.snp.makeConstraints { (make) in
            make.centerY.height.equalToSuperview()
            make.right.equalToSuperview().offset(-8)
            make.left.equalToSuperview().offset(8)
        }
        bgView.addSubview(taskName)
        bgView.addSubview(taskTime)
        bgView.addSubview(taskMember)
        bgView.addSubview(taskState)
        
        taskName.textColor = UIColor(hexString: "#040000")
        taskTime.textColor = UIColor(hexString: "#888888")
        taskMember.textColor = UIColor(hexString: "#b2b2b2")
        taskState.textColor = UIColor(hexString: "#2683f5")
        
        taskName.font = UIFont.init(name: "PingFang SC", size: 18)
        taskTime.font = UIFont.init(name: "PingFang SC", size: 14)
        taskMember.font = UIFont.init(name: "PingFang SC", size: 14)
        taskState.font = UIFont.init(name: "PingFang SC", size: 14)
        
        taskName.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(20)
            make.top.equalToSuperview().offset(11)
        }
        taskTime.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-19)
            make.centerY.equalTo(taskName)
        }
        taskMember.snp.makeConstraints { (make) in
            make.left.equalTo(taskName.snp.left)
            make.bottom.equalToSuperview().offset(-11)
        }
        taskState.snp.makeConstraints { (make) in
            make.right.equalTo(taskTime.snp.right)
            make.bottom.equalTo(taskMember.snp.bottom)
        }
        
    }
    
    func setText(modle:MyTaskModle){
        taskName.text = modle.name
        taskTime.text = modle.time + "截止"
        taskMember.text = "指派人: " + modle.member
        taskState.text = modle.state.rawValue
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
